package com.edu.d10_generic_limit;

import java.util.ArrayList;

/**
 * 泛型通配符上限、下限案例
 */
public class GenericDemo {
    public static void main(String[] args) {
        ArrayList<BaoMa> list = new ArrayList<>();
        list.add(new BaoMa());
        list.add(new BaoMa());
        list.add(new BaoMa());
        list.add(new BaoMa());
        go(list);
        //list.add(new BenChi());报错
        ArrayList<BenChi> list1 = new ArrayList<>();
/*        list1.add(new BaoMa());
        list1.add(new BaoMa());
        list1.add(new BaoMa());
        list1.add(new BaoMa());*/
        list1.add(new BenChi());
        go(list1);

/*        ArrayList<Dog> list2 = new ArrayList<>();
        list2.add(new Dog());
        go(list2);报错*/
    }
    public static void go(ArrayList<? extends Car> cars){

    }
}

class Dog{

}
class BaoMa extends Car{

}
class BenChi extends Car{

}

class Car{

}
